package com.chennan.project.api.rest.controller;

import com.chennan.common.domian.ResponseData;
import com.chennan.project.api.rest.controller.dto.LoginDTO;
import com.chennan.redis.domain.service.RedisService;
import com.chennan.redis.domain.service.RedisServiceComplete;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chennan
 * @createTime 2021年07月29日 15:54:00
 */
@RestController
@Api(tags="拼图前端接口")
@RequestMapping("/pingtu")
public class PingTuController {

    @Autowired
    private RedisServiceComplete redisService;

    @PostMapping("/exist-user")
    @ApiOperation("查询是否存在该用户")
    public ResponseData existUser(@RequestBody LoginDTO loginDTO){
        String s = redisService.get(loginDTO.getName());
        if (StringUtils.isEmpty(s)) {
            return ResponseData.error("你没注册了，不能谁便玩，给你个图体会一下！");
        }
        return ResponseData.sesscess(s);
    }
}
